﻿/*
 *
 * NOTE:
 *      Does this class have memory leak ?
 *
 */

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;

namespace Snowdreamist.Collection
{
    public class ReadonlyConcurrentObservableCollection<T> : ReadonlyConcurrentCollection<T>, INotifyCollectionChanged, ICollection<T>, IList<T>
    {
        public ReadonlyConcurrentObservableCollection(ConcurrentObservableCollection<T> collection)
            : base(collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");
            this._collection = collection;
            this._collection.CollectionChanged += new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
        }

        protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args)
        {
            if (this.CollectionChanged != null)
                this.CollectionChanged(this, args);
        }

        public event NotifyCollectionChangedEventHandler CollectionChanged;

        #region private

        private ConcurrentObservableCollection<T> _collection;

        private void Collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            this.OnCollectionChanged(e);
        }

        #endregion private
    }
}